﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;

public partial class User_RemotePost : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string FormName = "FORM1";
            string Method = "POST";
            string requestUrl = Request["RequestUrl"];          
            Response.Write("<html><head>");
            Response.Write(String.Format("</head><body onload='document.{0}.submit()'>", FormName));
            Response.Write(String.Format("<form name='{0}' method='{1}' action='{2}' >", FormName, Method, requestUrl));
            NameValueCollection pColl = Request.Params;
            for (int i = 0; i < pColl.Count; i++ )         
                System.Web.HttpContext.Current.Response.Write(String.Format("<input name='{0}' type='hidden' value='{1}'>", pColl.Keys[i], pColl.GetValues(pColl.Keys[i])[0]));            
            System.Web.HttpContext.Current.Response.Write("</form>");
            System.Web.HttpContext.Current.Response.Write("</body></html>");
            System.Web.HttpContext.Current.Response.End();
            Response.Redirect(requestUrl);
        }
        else
        {
            Response.Redirect("/");
        }
    }
}